/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assisisw.smartcal.utilities;

import java.util.Date;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import org.primefaces.component.outputlabel.OutputLabel;

/**
 *
 * @author Francesco
 */
public final class Utilities 
{

    // Static Fields
    
    public static final String EMAIL_REGEXP = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
        + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
    
    // Static Methods
    
    /***/
    public static final void pageMasterErrorManagement () 
    {
        OutputLabel outputText ;
        UIViewRoot root ;
        root = new UIViewRoot () ;
        outputText = new OutputLabel () ;
        outputText.setValue ( "Sorry, master error !" ) ;
        FacesContext.getCurrentInstance().setViewRoot ( new UIViewRoot());
        root.addComponentResource ( FacesContext.getCurrentInstance() , outputText ) ;
        FacesContext.getCurrentInstance().responseComplete();
        FacesContext.getCurrentInstance().renderResponse();
    }
    
    public static final boolean equalsByDay ( Date d0 , Date d1 ) 
    {
        boolean res ;
        if ( d0 != null && d1 != null )
            res = d0.getYear () == d1.getYear () && d0.getDate() == d1.getDate () && d0.getDate () == d1.getDate () ;
        else
            throw new IllegalArgumentException () ;
        return res ;
    }
    
    // Instance Methods
    
    /***/
    private Utilities () {}
    
}
